home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
dskut
/
dfa13.zip
/
DFA13.ASM
< prev
next >
Wrap
Assembly Source File
|
1986-11-20
|
19KB
|
797 lines
title DFA13 - DOS File Accelerator version 1.3
page 60,132
;
; DFA13 - DOS File Accelerator v1.3 20-Nov-86, S.H.Smith
;
; DFA is a small resident utility that can "accelerate" file access
; in many programs.
;
; DFA predicts when your program will want to read from a file and
; reads the data into a buffer before it is asked for. This is the
; opposite of a "cache" type program. A cache keeps data AFTER it has
; been used; DFA gets data BEFORE it is needed.
;
; WARNING: This program goes between your programs and DOS and had
; the potential of causing data loss. Make sure you have made a backup
; before you try this program.
;
; Written by Samuel H. Smith, 24-may-86
; Assemble with MASM v4.0
;
;----------------------------------------
;
public bufsize,maxread,status,readhits,realreads,handle,bytesinbuf
public position,seek_hi,seek_lo,bytesread,oldintvec,retip
public nametabl,namechg
code segment
assume cs:code,ds:nothing,es:nothing,ss:nothing
org 100h
entry:
jmp startup
;----------------------------------------
; program configuration and statistics (these should not be moved)
;
bufsize dw 4000h ;size of the file buffer.
;can be up to 0FC00H.
maxread dw 1000h ;largest data read size that will enable
;buffering on a file.
;larger initial reads will not be buffered.
readhits dw 0 ;count of reads that were satisfied by the buffer
realreads dw 0 ;count of real reads done through dos on buffered files
bytesinbuf dw 0 ;number of bytes currently in the buffer
namechg db 0 ;flags that one of the captured filenames has changed
;space for the filenames for each of the 20 handles
nametabl db 1280 dup (0)
; a binary signature hex 'DFAC' used to tell if DFA is already present
binsig dw 0DFACh
;----------------------------------------
; file status variables
;
status db 0 ;acceleration status
ready = 0 ;ready to accelerate
recursion = 088h ;using interrupt recursion
disabled = 0ffh ;disabled
nohandle equ word ptr 03333h
;special handle value when there is no current handle
handle dw nohandle ;the file handle for the current file
position dw 0 ;the next read position of the current file
;from the local buffer
seek_hi dw 0 ;32 bit base position for current file
seek_lo dw 0
bytesread dw 0 ;number of bytes read in current readfrombuf call
openmode dw 0 ;open access code for last open/creat
nameseg dw 0
nameofs dw 0
; a signature in bytes ($ terminated)
signature db 13,10,'DOS File Accelerator v1.3 (SHS, 20-Nov-86)'
db 13,10,'Public domain material. Personal use only.'
db 13,10,'$'
db 13,10,'by Samuel H. Smith',
db 13,10,' 5119 N. 11th Ave 332'
db 13,10,' Phoenix, Az 85013'
db 13,10
db 1ah
;----------------------------------------
; working storage
;
; vector for old interrupt
oldintvec dd 0
; user return data
retip dd 0
retflag dw 0
localip dw 0
;----------------------------------------
; macros
;
jbz macro lab
jb lab
jz lab
endm
jahz macro val,lab
cmp ah,val
jz lab
endm
display macro text
push ds
push cs
pop ds
mov dx,offset text
mov ah,9
int 21h
pop ds
endm
;========================================
; new interrupt service
;----------------------------------------
newint:
public newint
cmp status,disabled ;is DFA disabled?
jz useold
jahz 00h,doreset ;terminate program?
jahz 31h,doreset ;keep process?
jahz 4bh,doreset ;exec?
jahz 4ch,doreset ;terminate?
cmp status,ready ;are we already in an interrupt?
jnz useold
jahz 3ch,doopen ;create function?
jahz 3dh,doopen ;open function?
jahz 3eh,doclose ;close function?
jahz 3fh,doread ;read function?
jahz 40h,dowrite ;write function?
cmp ah,42h ;lseek function?
jnz useold
jmp doseek
;----------------------------------------
; use old interrupt handler
;----------------------------------------
useold:
public useold
jmp oldintvec ;jump to the real DOS handler
page
;----------------------------------------
; doreset - process DOS functions that reset all files
;----------------------------------------
doreset proc near
public doreset
cmp handle,nohandle
jz resetx ;use old handler if no current file
call setfilepos ;set file position and let dos take over
resetx:
mov status,ready ;clear recursion flag because sometimes
;dos never returns (as with ctrl-break)
jmp useold ;let dos do it's work
doreset endp
;----------------------------------------
; doopen - process DOS open function
;----------------------------------------
doopen proc near
public doopen
mov openmode,ax
mov nameseg,ds
mov nameofs,dx
call calldos ;let DOS open the file
pushf
jc openex
call grabname ;grab and keep the filename
cmp handle,ax ;if its not the current file handle
jnz openex ;then there's nothing more to do
mov handle,nohandle ;we just re-opened the current file -
;reset handle to purge previous buffering
openex:
popf
jmp return
doopen endp
;----------------------------------------
; dowrite - process DOS functions that close or modify files
;----------------------------------------
dowrite proc near
public dowrite
cmp bx,handle
jnz writex ;use old handler if no current file
call setfilepos ;set file position and let dos take over
writex:
jmp useold ;and let dos do it's work
dowrite endp
;----------------------------------------
; doclose - process DOS functions that close or modify files
;----------------------------------------
doclose proc near
public doclose
call dropfile
cmp bx,handle
jnz closex ;use old handler if no current file
call setfilepos ;set file position and let dos take over
closex:
jmp useold ;and let dos do it's work
doclose endp
page
;----------------------------------------
; doread - process DOS read function
;
; This procedure is the heart of the program. It will decide if
; read requests should be buffered or processed by DOS.
; It switches buffering to a new file when needed.
;----------------------------------------
doread proc near
public doread
cmp bx,handle ;is this the current file?
jz readagain ;then read from it again
cmp cx,maxread ;is this read for a fairly small buffer?
jb readswitch ;switch buffering to this file if it is
inc realreads ;count this as a "real" read through dos
inc readhits ;count this as a "logical" read through dos
jmp useold ;just let DOS do the read
;and keep the current file
;
; time to switch buffering to a different file
;
readswitch:
public readswitch
cmp handle,nohandle ;is there a current file?
jz newfile ;open new file if not
; unbuffer the current file
call setfilepos ;there is a current file - reset it to it's
;current position so DOS can take over on later
;read requests.
;
; start buffering a new file
;
newfile:
public newfile
mov namechg,1
mov handle,bx ;make this the new cur